/**
 * Created by Administrator on 2017/4/7.
 */




    // window.OrderId=696;
var OrderId = window.data.id;
$(function () {
    //------初始化一些数据------------//
    Date.prototype.Format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    };
    var RentMoney = 0;
    var RefuelMoney = 0;
    var SafetyChair = 0;
    var Driving = 0;
    var Violate = 0;
    var Overtime = 0;
    var Paid = 0;
    var Sum = 0;
    var otherfree = 0;
    var nowTime = new Date().Format("yyyy-MM-dd hh:mm");
    var takeCarFee = 0;
    var backCarFee = 0;
    var bujimianpeifee = 0;
    var jiayoufee = 0;
    var xuzufee = 0;
    var dingsunfee = 0;
    var yidihuanchefee = 0;
    var baoxianfee = 0;
    var GPSfee = 0;
    var weizhangfee = 0;
    var shangmensongchefee = 0;
    var shangmenquchefee = 0;
    var shouxu = 0;
    var chuliSateAll = true;
    //------------------//
    //----只需再orderStatus函数传入id----//
    var weizhangfeitotal = 0;
    breakRules(OrderId);
    function orderStatus(id) {
        var arguments = {
            id: id
        };
        $.ajax({
            url: ctx + '/rentorder/selectRentOrder',
            type: "GET",
            data: arguments,
            success: function (data) {
                data.state = [
                    {stateName: "客户下单"},
                    {stateName: "已确认"},
                    {stateName: "服务中"},
                    {stateName: "已还车"},
                    {stateName: "已完成"}
                ];
                findCar(data.carId);
                //--订单信息=------------//
                var dingdanhao = '<div>' + '<span>订单号:</span><p class="orderNo">' + (data.orderNo) + '</p></div>';
                var quche = '<div>' + '<span>取车地址:</span>' + (data.takeCarWay == 1 ? data.startAddress : "门店自取") + '</div>';
                var huanche = '<div>' + '<span>还车地址:</span>' + (data.backCarWay == 1 ? data.endAddress : '门店自还') + '</div>';
                var a = '<div>' + '<span>创建时间:</span>' + (data.created ? $.fn.Timestamp.TimestampDate(data.created) : "暂未信息") + '</div>';
                // var b = '<div>' + '<span>订单类型:</span></div>';
                var c = '<div>' + '<span>预计还车时间:</span>' + (data.rentTime ? $.fn.Timestamp.TimestampDate(data.rentTime) : "无") + '</div>';
                var d = '<div>' + '<span>实际还车时间:</span>' + (data.backCarTime ? $.fn.Timestamp.TimestampDate(data.backCarTime) : '无') + '</div>';
                var f = '<div>' + '<span>客户姓名:</span>' + (data.passengerName ? data.passengerName : "暂无") + '</div>';
                var g = '<div><span>客户电话:</span><input id="phone" value="' + (data.passengerPhone ? data.passengerPhone : "暂无") + '"></div>';
                //--付款信息------------//
                var h = '<div><span>租金:</span><span class="yang">￥' + (data.rentFee ? data.rentFee : 0) + '</span>元' + '</div>';
                var i = '<div><span>违章押金:</span><span class="yang">￥' + (data.peccancyForegift ? data.peccancyForegift : 0) + '</span>元' + '</div>';
                var j = '<div><span>加油费:</span><span class="yang">￥' + (data.gasFee ? data.gasFee : 0) + '</span>元' + '</div>';
                var k = '<div><span>不计免赔:</span><span class="yang">￥' + (data.noDeductible ? data.noDeductible : 0) + '</span>元' + '</div>';
                var l = '<div><span>配司机:</span><span class="yang">￥' + (data.driverFee ? data.driverFee : 0) + '</span>元' + '</div>';
                var m = '<div><span>儿童安全座椅:</span><span class="yang">￥' + (data.safetySeatFee ? data.safetySeatFee : 0) + '</span>元' + '</div>';
                var n = '<div><span>基本保险费:</span><span class="yang">￥' + (data.insurance ? data.insurance : 0) + '</span>元' + '</div>';
                var p = '<div><span>异地还车:</span><span class="yang">￥' + (data.remoteBackFee ? data.remoteBackFee : 0) + '</span>元' + '</div>';
                var q = '<div><span>续租费:</span><span class="yang">￥' + (data.reRentFee ? data.reRentFee : 0) + '</span>元' + '</div>';
                var r = '<div><span>GPS费:</span><span class="yang">￥' + (data.gpsFee ? data.gpsFee : 0) + '</span>元' + '</div>';
                var s = '<div><span>合计:</span><span class="yang">￥' + (data.totalFee ? data.totalFee : 0) + '</span>元' + '</div>';
                var cc = '<div><span>违章费用:</span><span class="yang">￥' + weizhangfeitotal + '</span>元' + '</div>';
                var aa = '<div><span>上门送车费:</span><span class="yang">￥' + (data.takeCarFee ? data.takeCarFee : 0) + '</span>元' + '</div>';
                var pry = '<div><span>租车押金:</span><span class="yang">￥' + (data.prepayRent ? data.prepayRent : 0) + '</span>元' + '</div>';
                var bb = '<div><span>上门取车费:</span><span class="yang">￥' + (data.backCarFee ? data.backCarFee : 0) + '</span>元' + '</div>';
                var dd = '<div><span>手续费:</span><span class="yang">￥' + (data.counterFee ? data.counterFee : 0) + '</span>元' + '</div>';
                var t = '<div><span>已支付:</span><span class="yang">￥' + (data.payed ? data.payed : 0) + '</span>元' + '</div>';
                RentMoney = parseFloat(data.rentFee);
                RefuelMoney = parseFloat(data.gasFee);
                SafetyChair = parseFloat(data.safetySeatFee);
                Driving = parseFloat(data.driverFee);
                Paid = parseFloat(data.payed);
                bujimianpeifee = parseFloat(data.noDeductible ? data.noDeductible : 0);
                weizhangfee = parseFloat(weizhangfeitotal);
                GPSfee = parseFloat(data.gpsFee ? data.gpsFee : 0);
                xuzufee = parseFloat(data.reRentFee ? data.reRentFee : 0);
                yidihuanchefee = parseFloat(data.remoteBackFee ? data.remoteBackFee : 0);
                jiayoufee = parseFloat(data.gasFee ? data.gasFee : 0);
                baoxianfee = parseInt(data.insurance ? data.insurance : 0);
                shangmensongchefee = parseFloat(data.takeCarFee ? data.takeCarFee : 0);
                shangmenquchefee = parseFloat(data.backCarFee ? data.backCarFee : 0);
                shouxu = parseFloat((data.counterFee ? data.counterFee : 0));
                if (data.takeCarFee == null) {
                    data.takeCarFee = 0
                }
                if (data.backCarFee == null) {
                    data.backCarFee = 0;
                }
                takeCarFee = parseFloat(data.takeCarFee);
                backCarFee = parseFloat(data.backCarFee);


                $(".OrderInformation").find(".right").append(h, j, k, l, m, n, p, aa, bb, r, q, cc, dd, t, s);

                $(".OrderInformation").find(".left").append(dingdanhao,quche,huanche,a, c, d, f, g, i, pry);


                $(".OrderStatus").find("CustomOrderStatus").remove();
                $(".OrderStatus").OrderStatus(data);

                //-----------还车时间--------------//
                var nowTemp = new Date();
                var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);


                $('#botsix').datetimepicker({
                    format: "yyyy-mm-dd HH:ii",
                    language: 'zh-CN',
                    showMeridian: true,
                    autoclose: true,
                    todayBtn: true,
                    startDate: $().Timestamp.TimestampDate(data.created)
                });
                //-------------------------//
                var otherFreeMod = $(' .otherFree .number');
                otherFreeMod.text(otherfree);
                var RentMoneyMod = $(' .RentMoney1 .number');
                RentMoneyMod.text(RentMoney);
                var RefuelMoneyMod = $(' .RefuelMoney .number');
                RefuelMoneyMod.text(RefuelMoney);
                var SafetyChairMod = $(' .SafetyChair .number');
                SafetyChairMod.text(SafetyChair);
                var DrivingMod = $(' .Driving .number');
                DrivingMod.text(data.driverFee ? data.driverFee : 0);
                var ViolateMod = $(' .Violate .number');
                ViolateMod.text(Violate);
                var OvertimeMod = $(' .Overtime .number');
                OvertimeMod.text(Overtime);
                var PaidMod = $(' .Paid .number');
                PaidMod.text(Paid);
                var SumMod = $(' .Sum .number');
                SumMod.text(Sum);
                var NowtimeMod = $("#botsix")
                NowtimeMod.val(nowTime);
                var takeCarFeeMod = $(".takeCarFee .number");
                takeCarFeeMod.text(takeCarFee);
                var backCarFeeMod = $(".backCarFee .number");
                backCarFeeMod.text(backCarFee);
                var bujimianpeifeeMod = $(".bujimianpeiFee .number");
                bujimianpeifeeMod.text(bujimianpeifee);
                var jiayoufeeMod = $(".jiayouFee .number");
                jiayoufeeMod.text(jiayoufee);
                var GPSfeeMod = $(".GPSFee .number");
                GPSfeeMod.text(GPSfee);
                var baoxianfeeMod = $(".jibenbaoxianFee .number");
                baoxianfeeMod.text(baoxianfee);
                var yidihuanchefeeMod = $(".yidihuancheFee .number");
                yidihuanchefeeMod.text(yidihuanchefee);
                var weizhangfeeMod = $(".weizhangFee .number");
                weizhangfeeMod.text(weizhangfee);
                var dingshunfeeMod = $(".dingsun .number");
                dingshunfeeMod.text(dingsunfee);
                var shouxufeiMod = $(".shouxufei .number");
                shouxufeiMod.text(shouxu);
                var xucuFeeMod = $('.xuzuFee .number');
                xucuFeeMod.text(xuzufee);
                function totalMoney() {
                    var RentMoney1 = parseFloat($(".RentMoney1").find(".number").text()) || 0;
                    var RefuelMoney = parseFloat($(".RefuelMoney").find(".number").text()) || 0;
                    var SafetyChair = parseFloat($(".SafetyChair").find(".number").text()) || 0;
                    var takecarfee = parseFloat($('.takeCarFee').find(".number").text()) || 0;
                    var backcarfee = parseFloat($('.backCarFee').find(".number").text()) || 0;
                    var yidihuanchefei = parseFloat($('.yidihuancheFee').find(".number").text()) || 0;
                    var jibenbaoxianfei = parseFloat($('.jibenbaoxianFee').find(".number").text()) || 0;
                    var jiayoufei = parseFloat($('.jiayouFee').find(".number").text()) || 0;
                    var GPSfei = parseFloat($('.GPSFee').find(".number").text()) || 0;
                    var xuzufei = parseFloat($('.xuzuFee').find(".number").text()) || 0;
                    var bujimianpeifei = parseFloat($('.bujimianpeiFee').find(".number").text()) || 0;
                    var weizhawngfei = parseFloat($('.weizhangFee').find(".number").text()) || 0;
                    var Driving = parseFloat($(".Driving").find(".number").text()) || 0;
                    var Violate = parseFloat($(".Violate").find(".number").text()) || 0;
                    var Paid = parseFloat($(".Paid").find(".number").text()) || 0;
                    var Overtime = parseFloat($(".Overtime").find(".number").text()) || 0;
                    var otherFree = parseFloat($(".otherFree").find(".number").text()) || 0;
                    var couterFee = parseFloat($('.shouxufei').find(".number").text()) || 0;
                    var dingsunfeea = parseFloat($(".dingsun").find(".number").text()) || 0;


                    var total = $().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.Subtr($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd($().Calculation.accAdd(RentMoney1, RefuelMoney), SafetyChair), takecarfee), backcarfee), yidihuanchefei), jibenbaoxianfei), jiayoufei), GPSfei), xuzufei), bujimianpeifei), weizhawngfei), Driving), Violate), Paid), RefuelMoney), Overtime), otherFree), couterFee), dingsunfeea);

                    return total
                }

                $(".changeCost").find('.Costspan1').text('立即支付');
                $('.Sum').text(parseFloat(totalMoney()));
                $(".changeCost").find('.Costspan2').text(totalMoney() + "元");
                //------------------------退还--------------------------//
                if (!data.isBackPeccancyForegift == 2) {
                    var peccancy = data.peccancyForegift;
                    var peccancyForegift = $("<div class='peccancyForegift'>违章预授额度:￥<span class='peccancy'></span><button class='button11' type='button'>退还违章押金</button></div>");
                    $(".GivenBeforehand").append(peccancyForegift);
                    $(".peccancy").text(peccancy);
                    var button11Statrt = true;
                    $(document).on('click', ".button11", function () {
                        if (button11Statrt) {
                            button11Statrt = false;
                            var options = {
                                data: {
                                    Title: "温馨提示",
                                    Content: "确认退还违章押金？",
                                    OkChange: function () {
                                        var arguments = {
                                            id: OrderId,
                                            type: 1
                                        };
                                        $.ajax({
                                            url: ctx + '/rentorder/backForegift',
                                            type: "POST",
                                            data: arguments,
                                            success: function (data) {
                                                if (data.message == "退还成功") {
                                                    $("body").Overlays({data: {text: data.message, state: 'Ok'}})
                                                } else {
                                                    $("body").Overlays({data: {text: data.message, state: 'No'}})
                                                }
                                            }
                                        })
                                    },
                                    CancelChange: function () {
                                        button11Statrt = true;
                                    }
                                }
                            };
                            $("body").ModalBox(options);
                        }

                    })
                }
                if (!data.isBackPrepayRent == 2) {
                    var prepayRent = data.prepayRent;
                    var prepay = $("<div class='prepayRent'>租车预授额度:￥<span class='prepay'></span><button type='button' class='button22'>退还租车押金</button></div>");
                    $(".GivenBeforehand").append(prepay);
                    $(".prepay").text(prepayRent);
                    var button11Statrt = true;
                    $(document).on('click', '.button22', function () {
                        if (button11Statrt) {
                            button11Statrt = false;
                            var options = {
                                data: {
                                    Title: "温馨提示",
                                    Content: "确认退还租金押金？",
                                    OkChange: function () {
                                        var arguments = {
                                            id: OrderId,
                                            type: 0
                                        };
                                        $.ajax({
                                            url: ctx + '/rentorder/backForegift?',
                                            type: "POST",
                                            data: arguments,
                                            success: function (data) {
                                                if (data.message == "退还成功") {
                                                    $("body").Overlays({data: {text: data.message, state: 'Ok'}})
                                                } else {
                                                    $("body").Overlays({data: {text: data.message, state: 'No'}})
                                                }
                                            }
                                        })
                                    },
                                    CancelChange: function () {
                                        button11Statrt = true;
                                    }
                                }
                            };
                            $("body").ModalBox(options);
                        }

                    })
                }
                //----------------------操作后--------------------------//
                $("#botone").on("input", function () {
                    $(".Overtime").find(".number").text($(this).val());
                    $('.Sum').text(totalMoney());
                    $(".changeCost").find('.Costspan2').text(totalMoney() + "元");
                });
                $("#bottwo").on("input", function () {
                    $(".Violate").find(".number").text($(this).val());
                    $('.Sum').text(totalMoney());
                    $(".changeCost").find('.Costspan2').text(totalMoney() + "元");
                })
                $("#botthree").on("input", function () {
                    $(".otherFree").find(".number").text($(this).val());
                    $('.Sum').text(totalMoney());
                    $(".changeCost").find('.Costspan2').text(totalMoney() + "元");
                })
                $("#botsenven").on("input", function () {
                    $(".dingsun").find(".number").text($(this).val());
                    $('.Sum').text(totalMoney());
                    $(".changeCost").find('.Costspan2').text(totalMoney() + "元");
                })

                //-------保存-------//

                var clickState = true;
                var weistatr = true;
                var jiestatr = true;
                $(".AnNiu").find(".save").on("click", function () {
                    if (clickState) {
                        clickState = false;
                        if (!chuliSateAll) {
                            if (weistatr) {
                                weistatr = false;
                                var quren = {
                                    data: {
                                        Title: "温馨提示",
                                        Content: "您有违章未处理，请处理后重试！",
                                        OkChange: function () {
                                            weistatr = true;
                                            clickState = true;
                                        },
                                        CancelChange: function () {
                                            weistatr = true;
                                            clickState = true;
                                        }
                                    },
                                };
                                $('body').ModalBox(quren);

                                return false
                            }

                        }
                        if (!$('.queren').is(':checked')) {
                            if (jiestatr) {
                                jiestatr = false;
                                var quren = {
                                    data: {
                                        Title: "温馨提示",
                                        Content: "您未结算，请先确认勾选后保存",
                                        OkChange: function () {
                                            jiestatr = true;
                                            clickState = true;
                                        },
                                        CancelChange: function () {
                                            jiestatr = true;
                                            clickState = true;
                                        }
                                    }
                                };
                                $('body').ModalBox(quren);

                                return false
                            }

                        }
                        var paytype = 4;
                        var totalFee = parseFloat($(".Sum").text()) + parseFloat(data.payed);
                        var phone = $("#phone").val();
                        var overTime = $("#botone").val();
                        var breakRules = $("#bottwo").val();
                        var other = $("#botthree").val();
                        var memo = $("#botfour").val();
                        var error = $("#botfive").val();
                        var dingshunfei = $("#botsenven").val();
                        var backCarTime = $.fn.Timestamp.DateTimestamp($("#botsix").val());
                        var payid = parseFloat($(".Sum").text());
                        var peccancyFee = weizhangfee;

                        var arguments = {
                            id: OrderId,
                            error: error,
                            otherFee: other,
                            memo: memo,
                            passengerPhone: phone,
                            overtimeFee: overTime,
                            violationFee: breakRules,
                            backCarTime: backCarTime,
                            totalFee: totalFee,
                            isPay: paytype,
                            payed: payid,
                            assessFee: dingshunfei,
                            peccancyFee: peccancyFee
                        };


                        $.ajax({
                            url: ctx + '/rentorder/back',
                            type: "POST",
                            data: arguments,
                            success: function (data) {
                                if (data.message == '订单状态修改成功') {
                                    $('body').Overlays({data: {text: '保存成功！', state: "Ok"}});
                                    setInterval(function () {
                                        window.location.href = ctx + '/rentorder/serverlist'
                                    }, 2000)()
                                } else {
                                    $('body').Overlays({data: {text: '保存失败，请稍后重试！', state: "No"}});
                                    clickState = true;
                                }
                            }
                        })
                    }


                });
                //-------返回-------//
                $(".AnNiu").find(".return").on("click", function () {
                    window.history.back(-1);
                })
            }
        })
    }

    function breakRules(id) {
        var arguments = {
            orderId: id
        };
        $.ajax({
            url: ctx + '/rentorder/selectPeccancysByOrderId',
            type: "GET",
            data: arguments,
            success: function (data) {
                var EndorsementOption = {
                    data: {
                        Thead: {b: "违章时间", k: "违章地点", c: "违章分数", d: "违章罚款(元)", e: "违章描述", f: "操作"},
                        Tbody: []
                    }
                };

                for (var i = 0; i < data.length; i++) {
                    (function () {
                        var index = i;
                        var Val = {
                            b: $.fn.Timestamp.TimestampDate(data[i].time),
                            k: data[i].address,
                            c: data[i].deductMarks,
                            d: data[i].amerce,
                            e: data[i].reason,
                            ButtonAction: {
                                name: "处理",
                                Action: function () {
                                    var chuliSate = true;

                                    function chulifn() {
                                        if (chuliSate) {
                                            chuliSate = false;
                                            var timestamp = (new Date()).valueOf();
                                            var Dispose = {
                                                data: {
                                                    Title: '处理违章',
                                                    Content: '确认这个违章已处理？',
                                                    OkChange: function (e) {
                                                        $.ajax({
                                                            url: ctx + '/rentorder/postPeccancy',
                                                            data: {
                                                                id: data[index].id,
                                                                status: 1
                                                            },
                                                            type: 'POST',
                                                            success: function (data) {
                                                                if (data.message == '修改状态成功') {
                                                                    $('body').Overlays({
                                                                        data: {
                                                                            text: '处理违章成功！',
                                                                            state: 'Ok'
                                                                        }
                                                                    });
                                                                    breakRules(id);
                                                                } else {
                                                                    $('body').Overlays({
                                                                        data: {
                                                                            text: '处理违章失败，请稍后重试！',
                                                                            state: 'No'
                                                                        }
                                                                    })
                                                                }
                                                            }
                                                        });


                                                    }
                                                }
                                            };
                                            $('body').ModalBox(Dispose)
                                        }
                                    }

                                    chulifn()
                                }
                            }
                        };
                        if (data[i].status == 1) {
                            Val.ButtonAction = '已处理'
                        }

                        weizhangfeitotal += data[i].amerce;
                        EndorsementOption.data.Tbody.push(Val);
                    })();

                }
                (function () {
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].status == 1) {
                            chuliSateAll = true;
                        } else {
                            chuliSateAll = false;
                            return;
                        }
                    }
                })();

                $(".Endorsement").find(".OrderTable").remove();
                $(".Endorsement").Order(EndorsementOption);
            }
        })

    }

    function findCar(vehicle) {
        var arguments = {
            id: vehicle
        };
        $.ajax({
            url: "http://192.168.0.79:8081/rentcar/findById",
            type: "GET",
            data: arguments,
            success: function (data) {
                var obj = eval('(' + data.data + ')'); //由JSON字符串转换为JSON对象
                var argument = {
                    id: obj.rentCar.shopId
                };
                $.ajax({
                    url: ctx + '/rentshop/selectRentshop',
                    type: "GET",
                    data: argument,
                    success: function (data1) {
                        var findCarOption = {
                            data: {
                                Thead: {
                                    vehicleName: "车辆名称",
                                    rent: "车辆租金",
                                    deposit: "违约押金",
                                    PreLicensing: "预授权",
                                    brand: "品牌",
                                    plateNumber: "车牌号",
                                    ownedStores: "所属门店",
                                    gearBox: "变速箱",
                                    carType: "车型",
                                    displacement: "排量",
                                    seats: "座位数",
                                    roadHaul: "行驶里程",
                                    location: "所在地",
                                    trafficControl: "限行"
                                },
                                Tbody: []
                            }

                        };
                        // console.log(obj);
                        var item = {
                            vehicleName: obj.rentCar == null ? "无" : obj.rentCar.carName,
                            rent: obj.vehicle.rent == null ? "0" : obj.vehicle.rent,
                            deposit: obj.vehicle.illegalDeposit == null ? "0" : obj.vehicle.illegalDeposit,
                            PreLicensing: obj.vehicle.pregrant == null ? "0" : obj.vehicle.pregrant,
                            brand: obj.vehicle.brandName == null ? "无" : obj.vehicle.brandName,
                            plateNumber: obj.car.plateNo == null ? "无" : obj.car.plateNo,
                            ownedStores: obj.rentCar.shopName == null ? "无" : obj.rentCar.shopName,
                            gearBox: obj.vehicle.transmission == null ? "无" : obj.vehicle.transmission,
                            carType: obj.vehicle.type == null ? "未知" : obj.vehicle.type,
                            displacement: obj.vehicle.displacement == null ? "未知" : obj.vehicle.displacement,
                            seats: obj.vehicle.seat == null ? "无" : obj.vehicle.seat,
                            roadHaul: obj.car.mileage == null ? "0" : obj.car.mileage,
                            location: data1.address == null ? "暂无信息" : data1.address,
                            trafficControl: ''
                        };

                        switch (obj.rentCar.limit) {
                            case 0:
                                item.trafficControl = "不限行";
                                break;
                            case 1:
                                item.trafficControl = "星期一";
                                break;
                            case 2:

                                item.trafficControl = "星期二";
                                break;
                            case 3:
                                item.trafficControl = "星期三";
                                break;
                            case 4:
                                item.trafficControl = "星期四";
                                break;
                            case 5:
                                item.trafficControl = "星期五";
                                break;
                            case 6:
                                item.trafficControl = "星期六";
                                break;
                            case 7:
                                item.trafficControl = "星期日";
                                break;
                        }

                        findCarOption.data.Tbody.push(item);
                        $(".CarInformation").Order(findCarOption);
                    }
                });

            }
        })
    }

    function CarAndSettlement(id) {
        var arguments = {
            orderId: id
        };
        $.ajax({
            url: ctx + '/rentorder/selectRentOrderStatus',
            type: "GET",
            data: arguments,
            success: function (data) {
                var TraceInformationOption = {
                    data: []
                };
                for (var i = 0; i < data.length; i++) {
                    TraceInformationOption.data.push(data[i]);
                }
                $(".traceInformation").find(".CustomTrace").remove();
                $(".traceInformation").TraceInformation(TraceInformationOption);

            }
        })
    }


    orderStatus(OrderId);
    CarAndSettlement(OrderId);

    //---返回---//
    $(".AnNiu").find(".return").on("click", function () {
        window.location.href = ctx + '/rentorder/serverlist'
    });
    /**选项卡**/
    $(".cont").find(".tab").eq(0).show();
    $(".tabs").find("li").each(function (index) {
        $(this).on("click", function () {
            $(this).addClass("TabAcLine");
            $(this).siblings().removeClass("TabAcLine");
            $(".cont .tab").eq(index).show();
            $(".cont .tab").eq(index).siblings().hide();
        })
    });

    for (var i = 0; i < $('input[type="number"]').length; i++) {
        (function () {
            var index = i;
            if (!index == 0) {
                $('input[type="number"]').eq(index).on('change', function () {
                    if ($(this).val() < 0) {
                        $(this).val(0)
                    }
                })
            }

        })()
    }

    // $('.clearfix').remove()
});



